# -*- coding: utf-8 -*-
"""
Created on  2019/8/30 13:18
@author: iris.wang
@file  : backend_related.py
desc: inews后台相关配置
"""

import logging
from util.db_util import execute_query

# 查询最新一条创建公告notice的id
def get_latest_notice_id():
    results = execute_query("SELECT id FROM nlp_news_notice order by crt desc")
    try:
        result = results[0][0]
        return result
    except Exception as e:
        logging.error("Retrieve latest notice failed!")
        return None


# 查询已发布的概念主题中最新一条概念theme_code
def get_latest_theme_code():
    results = execute_query("SELECT theme_code FROM nlp_news_theme WHERE state=1 ORDER BY upt")
    try:
        result = results[0][0]
        return result
    except Exception as e:
        logging.error("Retrieve latest theme_code failed!")
        return None